package com.example.function_interface.supplier;

import com.example.function_interface.User;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.function.BooleanSupplier;

/**
 * 代表了boolean值结果的提供方
 */
public class BooleanSupplierTest {

    @Test
    public void myTest() throws Exception{
        List<User> userList = new ArrayList<>();
        User user1 = new User(1, "张三", 12, false);
        User user2 = new User(2, "李四", 22, false);
        User user3 = new User(3, "王五", 32, true);
        User user4 = new User(4, "郑静", 2, true);
        userList.add(user1);
        userList.add(user2);
        userList.add(user3);
        userList.add(user4);

        BooleanSupplier booleanSupplier = new BooleanSupplier() {
            @Override
            public boolean getAsBoolean() {
                return user1.isMan();
            }
        };
        System.out.println(booleanSupplier.getAsBoolean());
    }
}
